"use strict";
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
        return typeof obj
    }
    : function(obj) {
        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj
    }
;
function _defineProperty(obj, key, value) {
    return key in obj ? Object.defineProperty(obj, key, {
        value: value,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : obj[key] = value,
        obj
}
var utils = {
    chatboxProp: {
        isVisit: 0,
        isChatBoxShow: 0,
        isServiceTime: 0
    },
    broswer: {
        IE6: "msie 6",
        IE7: "msie 7",
        IE8: "msie 8",
        IE9: "msie 9",
        IE10: "msie 10",
        IE11: "msie 11",
        Chrome: "chrome",
        Firefox: "firefox",
        Opera: "opera",
        Safari: "safari",
        Netscape: "netscape"
    },
    isFromMobile: function() {
        var agent = navigator.userAgent.toLowerCase()
            , ipad = agent.match(/(ipad).*os\s([\d_]+)/)
            , isIphone = !ipad && agent.match(/(iphone\sos)\s([\d_]+)/)
            , isAndroid = agent.match(/(android)\s+([\d.]+)/)
            , isWinPhone = agent.match(/(windows mobile)\s+([\d.]+)/);
        return ipad || isIphone || isAndroid || isWinPhone
    },
    isNewPageOpen: function() {
        var isNewPage = !1;
        return onlineData.openChatWay && "newPage" === onlineData.openChatWay && !utils.isFromMobile() && (isNewPage = !0),
            isNewPage
    },
    getBroswer: function() {
        var defaultBroswer = "netscape"
            , agent = navigator.userAgent.toLowerCase();
        if (/(msie|firefox|opera|chrome|netscape)\D+(\d[\d.*])/.test(agent)) {
            var name = RegExp.$1
                , versionNum = parseInt(RegExp.$2);
            "msie" == (defaultBroswer = name) && (defaultBroswer += " " + versionNum)
        } else
            /version\D+(\d[\d.]*).*safari/.test(agent) && (defaultBroswer = "safari");
        return defaultBroswer
    },
    eventOn: function(elem, eventtype, func) {
        (elem = "string" == typeof elem ? document.getElementById(elem) : elem).addEventListener ? elem.addEventListener(eventtype, func, !1) : elem.attachEvent ? elem.attachEvent("on" + eventtype, func) : elem["on" + eventtype] = func
    },
    getCookie: function(key) {
        for (var arrCookie = document.cookie.split("; "), i = 0; i < arrCookie.length; i++) {
            var arr = arrCookie[i].split("=");
            if (arr[0] == key)
                return arr[1]
        }
        return ""
    },
    setCookie: function(obj, value, exp, domain) {
        var cookieTime = 864e5;
        exp && "session" != exp && (cookieTime *= exp);
        var d = new Date;
        d.setTime(d.getTime() + cookieTime);
        var cookieExpires = "; expires=" + d.toGMTString()
            , domainStr = "";
        if (domain && null != domain && (domainStr = "; domain=" + domain),
        "string" == typeof obj)
            document.cookie = obj + "=" + encodeURIComponent(value) + ("session" == exp ? "" : cookieExpires) + domainStr + "; path=/";
        else
            for (var key in obj)
                document.cookie = key + "=" + encodeURIComponent(obj[key]) + ("session" == exp ? "" : cookieExpires) + domainStr + "; path=/"
    },
    makeQuery: function(json) {
        json = json || {};
        var query_arr = [];
        for (var key in json.__ = (new Date).getTime(),
            json) {
            var val = json[key];
            query_arr.push(key + "=" + encodeURIComponent(val))
        }
        return query_arr.join("&").replace(/%20/g, "+")
    },
    aniMove: function(element, position, speed, callback) {
        element.effect || (element.effect = {},
            element.effect.move = 0),
            clearInterval(element.effect.move);
        speed = speed || 30;
        var start = {
            left: element.offsetLeft,
            bottom: position.b,
            top: element.offsetTop,
            right: position.r
        }
            , style = element.style
            , parr = new Array;
        "number" == typeof position.left && parr.push("left"),
        "number" == typeof position.right && parr.push("right"),
        "number" == typeof position.bottom && parr.push("bottom"),
        "number" == typeof position.top && parr.push("top"),
            element.effect.move = setInterval(function() {
                for (var i = 0; i < parr.length; i++)
                    start[parr[i]] += (position[parr[i]] - start[parr[i]]) * speed / 100,
                        style[parr[i]] = start[parr[i]] + "px";
                for (i = 0; i < parr.length && Math.round(start[parr[i]]) == position[parr[i]]; i++)
                    if (i == parr.length - 1) {
                        for (i = 0; i < parr.length; i++)
                            style[parr[i]] = position[parr[i]] + "px";
                        clearInterval(element.effect.move),
                        callback && callback()
                    }
            }, 5)
    },
    chatBtnPosition: function() {
        var btn = document.getElementById("chatBtn")
            , data = onlineData;
        if (data.cssStyle.chatboxLocation) {
            if (btn.style.borderTopLeftRadius = "0px",
                btn.style.borderTopRightRadius = "0px",
                btn.style.borderBottomRightRadius = "0px",
                btn.style.borderBottomLeftRadius = "0px",
                btn.style.bottom = "",
                btn.style.padding = "",
            data.scheduleEnable && data.entranceNode) {
                var positionStyle = data.entranceNode.buttonStyle;
                data.cssStyle.onlineText = positionStyle.text,
                    data.cssStyle.chatButtonLocation = positionStyle.location,
                    data.cssStyle.chatboxIconType = positionStyle.iconType,
                    "circle-left" == positionStyle.location || "circle-right" == positionStyle.location ? (data.cssStyle.chatButtonSideMargin = positionStyle.sideMargin,
                        data.cssStyle.chatButtonBottomMargin = positionStyle.bottomMargin) : "bottom-left" == positionStyle.location || "bottom-right" == positionStyle.location ? data.cssStyle.chatButtonSideMargin = positionStyle.sideMargin : "side-left" != positionStyle.location && "side-right" != positionStyle.location || (data.cssStyle.chatButtonBottomMargin = positionStyle.bottomMargin),
                positionStyle.mobileBottomMargin && (data.cssStyle.chatButtonMobileBottomMargin = positionStyle.mobileBottomMargin),
                void 0 !== positionStyle.mobileText && (data.cssStyle.onlineMobileText = positionStyle.mobileText),
                positionStyle.mobileIconType && (data.cssStyle.chatboxMobileIconType = positionStyle.mobileIconType),
                positionStyle.mobileLocation && (data.cssStyle.chatButtonMobileLocation = positionStyle.mobileLocation),
                positionStyle.mobileSideMargin && (data.cssStyle.chatButtonMobileSideMargin = positionStyle.mobileSideMargin)
            }
            if (utils.isFromMobile() && data.cssStyle.chatButtonMobileLocation) {
                if ("circle-left" != data.cssStyle.chatButtonMobileLocation && "circle-right" != data.cssStyle.chatButtonMobileLocation && "levitate" != data.cssStyle.chatButtonMobileLocation || (btn.style.width = "25px",
                    btn.style.height = "25px",
                    btn.style.borderRadius = "55px",
                    btn.style.padding = "15px",
                    btn.getElementsByTagName("img")[0].style.width = "25px",
                    btn.getElementsByTagName("img")[0].style.height = "25px",
                    btn.getElementsByTagName("img")[0].style.margin = "0",
                    btn.getElementsByTagName("img")[0].style.padding = "0",
                    btn.getElementsByTagName("img")[0].style.transform = "unset",
                    btn.getElementsByTagName("img")[0].style.transition = "unset",
                    btn.getElementsByTagName("span")[0].innerHTML = ""),
                "circle-left" == data.cssStyle.chatButtonMobileLocation)
                    btn.style.left = data.cssStyle.chatButtonMobileSideMargin + "px",
                        btn.style.bottom = data.cssStyle.chatButtonMobileBottomMargin + "px";
                else if ("circle-right" == data.cssStyle.chatButtonMobileLocation)
                    btn.style.right = data.cssStyle.chatButtonMobileSideMargin + "px",
                        btn.style.bottom = data.cssStyle.chatButtonMobileBottomMargin + "px";
                else if ("bottom" == data.cssStyle.chatButtonMobileLocation)
                    btn.style.bottom = "-1px",
                        btn.style.padding = "8px 10px 8px 10px",
                        btn.style.borderTopLeftRadius = "5px",
                        btn.style.borderTopRightRadius = "5px";
                else if ("levitate" == data.cssStyle.chatButtonMobileLocation) {
                    btn.style.right = "18px",
                        btn.style.bottom = "18px";
                    var dragDom = document.getElementById("chatBtn");
                    qimosdk.startDrag(dragDom, dragDom)
                }
            } else
                "bottom-left" == data.cssStyle.chatButtonLocation ? (btn.style.left = data.cssStyle.chatButtonSideMargin + "px",
                    btn.style.bottom = "-1px") : "bottom-right" == data.cssStyle.chatButtonLocation ? (btn.style.right = data.cssStyle.chatButtonSideMargin + "px",
                    btn.style.bottom = "-1px") : "side-left" == data.cssStyle.chatButtonLocation ? (btn.style.left = "-1px",
                    btn.style.bottom = data.cssStyle.chatButtonBottomMargin + "px",
                    btn.style.borderBottomRightRadius = "5px",
                    btn.style.borderTopRightRadius = "5px") : "side-right" == data.cssStyle.chatButtonLocation ? (btn.style.right = "-1px",
                    btn.style.bottom = data.cssStyle.chatButtonBottomMargin + "px",
                    btn.style.borderTopLeftRadius = "5px",
                    btn.style.borderBottomLeftRadius = "5px") : "circle-left" == data.cssStyle.chatButtonLocation ? (btn.style.left = data.cssStyle.chatButtonSideMargin + "px",
                    btn.style.bottom = data.cssStyle.chatButtonBottomMargin + "px") : "circle-right" == data.cssStyle.chatButtonLocation && (btn.style.right = data.cssStyle.chatButtonSideMargin + "px",
                    btn.style.bottom = data.cssStyle.chatButtonBottomMargin + "px"),
                    "side-left" == data.cssStyle.chatButtonLocation || "side-right" == data.cssStyle.chatButtonLocation ? (btn.getElementsByTagName("span")[0].style.wordBreak = "break-all",
                        btn.getElementsByTagName("span")[0].style.wordWrap = "break-word",
                        btn.getElementsByTagName("span")[0].style.width = "14px",
                        btn.getElementsByTagName("span")[0].style.display = "block",
                        btn.getElementsByTagName("span")[0].style.padding = "0px 6px",
                        btn.style.padding = "10px 8px") : "circle-right" == data.cssStyle.chatButtonLocation || "circle-left" == data.cssStyle.chatButtonLocation ? (btn.style.width = "25px",
                        btn.style.height = "25px",
                        btn.style.borderRadius = "55px",
                        btn.style.padding = "15px",
                        btn.getElementsByTagName("img")[0].style.width = "25px",
                        btn.getElementsByTagName("img")[0].style.height = "25px",
                        btn.getElementsByTagName("img")[0].style.margin = "0",
                        btn.getElementsByTagName("img")[0].style.padding = "0",
                        btn.getElementsByTagName("img")[0].style.transform = "unset",
                        btn.getElementsByTagName("img")[0].style.transition = "unset",
                        btn.getElementsByTagName("span")[0].innerHTML = "") : "bottom-left" != data.cssStyle.chatButtonLocation && "bottom-right" != data.cssStyle.chatButtonLocation || (btn.getElementsByTagName("img")[0].style.margin = "0px 5px -6px 0px",
                        btn.style.padding = "8px 10px 8px 10px",
                        btn.style.borderTopLeftRadius = "5px",
                        btn.style.borderTopRightRadius = "5px");
            return {
                left: btn.style.left,
                right: btn.style.right,
                bottom: btn.style.bottom
            }
        }
        btn.style.right = "18px",
            btn.style.padding = "8px 10px 8px 10px",
            btn.style.borderTopLeftRadius = "5px",
            btn.style.borderTopRightRadius = "5px",
            btn.style.borderBottomRightRadius = "0px",
            btn.style.borderBottomLeftRadius = "0px"
    },
    isIE: function(ver) {
        var b = document.createElement("b");
        return b.innerHTML = "\x3c!--[if IE " + ver + "]><i></i><![endif]--\x3e",
        1 === b.getElementsByTagName("i").length
    },
    getCurrentDateDay: function() {
        var date = new Date
            , year = date.getFullYear()
            , month = date.getMonth()
            , day = date.getDate();
        return year + "-" + (month = 9 < month + 1 ? month + 1 : "0" + (month + 1)) + "-" + (day = 9 < day ? day : "0" + day)
    },
    getCurrentDateTime: function() {
        var date = new Date
            , hour = date.getHours()
            , minutes = date.getMinutes()
            , seconds = date.getSeconds();
        return (hour = 9 < hour ? hour : "0" + hour) + ":" + (minutes = 9 < minutes ? minutes : "0" + minutes) + ":" + (seconds = 9 < seconds ? seconds : "0" + seconds)
    },
    ajaxRequest: function(url, method, timeout, data, successCallback, errorCallback) {
        var ajaxParam = {
            type: method,
            url: url,
            timeout: timeout,
            cache: !1,
            success: successCallback,
            error: errorCallback
        };
        data && (ajaxParam.data = data),
            $.ajax(ajaxParam)
    },
    deepClone: function(targetObj) {
        var tempObj;
        if ("object" === (void 0 === targetObj ? "undefined" : _typeof(targetObj)))
            if (null === targetObj)
                tempObj = null;
            else if (targetObj instanceof Date)
                tempObj = targetObj;
            else if (targetObj instanceof Array) {
                tempObj = [];
                for (var i = 0, len = targetObj.length; i < len; i++)
                    tempObj.push(utils.deepClone(targetObj[i]))
            } else
                for (var j in tempObj = {},
                    targetObj)
                    tempObj[j] = utils.deepClone(targetObj[j]);
        else
            tempObj = targetObj;
        return tempObj
    },
    unReadMsgCountCallback: void 0,
    unReadMsgListCallback: void 0
}
    , styleColor = void 0
    , peers = void 0
    , lastReferrer = qimo_config.referrer
    , firstSeoRefer = utils.getCookie("qimo_firstSeoRefer")
    , seoUrl = ""
    , seoSource = ""
    , seoKeywords = ""
    , xstKeywords = ""
    , utm_source = ""
    , utm_medium = ""
    , utm_term = ""
    , utm_content = ""
    , utm_campaign = ""
    , skey = "qimo_seosource_" + qimo_config.accessId
    , kkey = "qimo_seokeywords_" + qimo_config.accessId
    , m7xstkey = "qimo_xstKeywords_" + qimo_config.accessId
    , unreadMessageCount = 0
    , openTimeout = 0
    , showNewMsgTimeout = 0
    , showNewMsgRight = -100
    , priority = !1
    , showAnnexUrl = !1
    , qimo_loaded = !1;
window.console = window.console || function() {
    var c = {};
    return c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function() {}
        ,
        c
}(),
Array.prototype.forEach || (Array.prototype.forEach = function(callback) {
        var T, k;
        if (null == this)
            throw new TypeError("this is null or not defined");
        var O = Object(this)
            , len = O.length >>> 0;
        if ("function" != typeof callback)
            throw new TypError(callback + " is not a function");
        for (1 < arguments.length && (T = arguments[1]),
                 k = 0; k < len; ) {
            var kValue;
            k in O && (kValue = O[k],
                callback.call(T, kValue, k, O)),
                k++
        }
    }
);
var getSeoParams = function() {
    if (seoUrl = firstSeoRefer ? decodeURIComponent(firstSeoRefer) : lastReferrer,
    utils.isNewPageOpen() && qimo_config.m7webchatpage) {
        var seoData = "qimo_chat_referrer_" + qimo_config.accessId
            , seoDataUrl = decodeURIComponent(utils.getCookie(seoData));
        lastReferrer = seoUrl = seoDataUrl
    }
    if ("" !== seoUrl) {
        var host = ""
            , temps = utils.getCookie(skey)
            , tempk = utils.getCookie(kkey)
            , tempxst = utils.getCookie(m7xstkey);
        if (seoUrl && (host = seoUrl.split("/")[2]),
        host == window.location.host)
            seoSource = temps ? decodeURIComponent(temps) : "站内",
                seoKeywords = tempk ? decodeURIComponent(tempk) : "",
                xstKeywords = tempxst ? decodeURIComponent(tempxst) : "";
        else if ("www.baidu.com" == host) {
            if (seoSource = "百度搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "wd" != temp[0] && "word" != temp[0] || (seoKeywords = temp[1]),
                    "xst" == temp[0] && "undefined" !== temp[1] && (xstKeywords = temp[1])
                })
        } else if ("m.baidu.com" == host) {
            if (seoSource = "百度搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "word" == temp[0] && (seoKeywords = temp[1]),
                    "xst" == temp[0] && "undefined" !== temp[1] && (xstKeywords = temp[1])
                })
        } else if ("www.so.com" == host) {
            if (seoSource = "360搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "q" == temp[0] && (seoKeywords = temp[1])
                })
        } else if ("m.so.com" == host) {
            if (seoSource = "360搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "q" == temp[0] && (seoKeywords = temp[1])
                })
        } else if ("www.sogou.com" == host) {
            if (seoSource = "搜狗搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "query" == temp[0] && (seoKeywords = temp[1])
                })
        } else if ("wap.sogou.com" == host) {
            if (seoSource = "搜狗搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "keyword" == temp[0] && (seoKeywords = temp[1])
                })
        } else if ("so.m.sm.cn" == host) {
            if (seoSource = "神马搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "keyword" == temp[0] && (seoKeywords = temp[1])
                })
        } else if ("www.google.com" == host) {
            if (seoSource = "Google搜索",
            0 < seoUrl.indexOf("?"))
                seoUrl.split("?")[1].split("&").forEach(function(query) {
                    var temp = query.split("=");
                    "q" == temp[0] && (seoKeywords = temp[1])
                })
        } else
            seoSource = "其他网站",
                seoKeywords = "未知",
                xstKeywords = ""
    } else
        seoSource = "站内",
            xstKeywords = seoKeywords = "";
    var href = window.location.href;
    0 < href.indexOf("?") && href.split("?")[1].split("&").forEach(function(query) {
        var temp = query.split("=");
        "utm_source" == temp[0] && (utm_source = temp[1]),
        "utm_medium" == temp[0] && (utm_medium = temp[1]),
        "utm_term" == temp[0] && (utm_term = temp[1]),
        "utm_content" == temp[0] && (utm_content = temp[1]),
        "utm_campaign" == temp[0] && (utm_campaign = temp[1])
    });
    seoSource || seoKeywords || xstKeywords ? (utils.setCookie(skey, seoSource, 1 / 48),
        utils.setCookie(kkey, seoKeywords, 1 / 48),
        utils.setCookie(m7xstkey, xstKeywords, 1 / 48)) : (utils.setCookie(skey, seoSource, -1),
        utils.setCookie(kkey, seoKeywords, -1),
        utils.setCookie(m7xstkey, xstKeywords, -1))
};
function QiMoIMSDK() {
    var self = this
        , sendBtnHtml = "发送";
    "en" === qimo_config.language && (sendBtnHtml = "send"),
        this.chatboxstyle = {
            html: "<div class='qimo_chatpup' id='qimo_chatpup' style='display: none; '><div style='' class='m7_dragbarChat' id='dragChat'></div><iframe id='chatIframe' src='' height='100%' width='100%'></iframe><div id='maskChat'></div></div><div id='chatBtn' class='chatBtn'></div><div id='qimo_showNewMsg' class='qimo_showNewMsg' style='display: none; '><div id='qimo_showNewMsg_box' class='qimo_showNewMsg_box'><div id='qimo_showNewMsg_title_box' class='qimo_showNewMsg_title_box'><img src='" + qimo_config.chatHost + "images/agentLogo.png'><span id='qimo_showNewMsg_title' class='qimo_showNewMsg_title'></span></div> <div id='qimo_showNewMsg_content' class='qimo_showNewMsg_content'></div></div><span id='qimo_showNewMsg_close' class='qimo_showNewMsg_close'>x</span></div>"
        },
        this.inviteBoxStyle = {
            html: "<div class='qimo_inviteBox' id='qimo_inviteBox' style='display: none; '><img class=\"qimo_invite_close\" id='qimo_invite_close' src='" + qimo_config.chatHost + 'images/invite-close.png\'><div class=\'qimo_inviteBox_top\'><div class="qimo_inviteBox_top_img" id="qimo_inviteBox_top_img"><img id="qimo_inviteBox_img" src=\'' + qimo_config.chatHost + 'images/defaultPhoto.png\'></div><div class="qimo_inviteBox_top_right" id="qimo_inviteBox_top_right"><p id="qimo_inviteBox_InviteWords"></p><div class="qimo_inviteBox_top_button" id="qimo_inviteBox_top_button"><div id="invite_click_button_1" class="divbuttons msie11PadTop">立即咨询</div><div id="invite_click_button_2" class="divbuttons msie11PadTop">稍后再说</div></div></div></div><div class=\'qimo_inviteBox_bottom\'><textarea id="sendInviteText" placeholder="请输入您想要输入的内容..." rows="2"></textarea><div id="sendInviteContent" class="sendInviteContent msie11PadTop">' + sendBtnHtml + "</div></div></div>"
        },
        this.init = function() {
            var data = {
                accessId: qimo_config.accessId,
                location: encodeURIComponent(window.location.host),
                referrer: document.referrer || "",
                callbackF: "getChatConfig",
                action: "getOnlineStates"
            };
            this.loadJsonp(qimo_config.companyConfigUrl, data)
        }
        ,
        this.loadJsonp = function(url, data) {
            var query = utils.makeQuery(data)
                , script = document.createElement("script");
            script.type = "text/javascript",
                script.setAttribute("charset", "UTF-8"),
                script.src = url + "?" + query;
            try {
                document.body.appendChild(script)
            } catch (e) {
                document.ready(function() {
                    document.body.appendChild(script)
                })
            }
        }
        ,
        this.loadVedioJs = function(url) {
            var script = document.createElement("script");
            script.type = "text/javascript",
                script.setAttribute("charset", "UTF-8"),
                script.src = url;
            try {
                document.body.appendChild(script)
            } catch (e) {
                document.ready(function() {
                    document.body.appendChild(script)
                })
            }
        }
        ,
        this.initChat = function(data, callback) {
            peers = data.peers;
            var isClick = !1;
            if (data.success) {
                var obj = {
                    href: window.location.href
                };
                utils.getCookie("href") || utils.setCookie(obj, "", "session"),
                    utils.setCookie({
                        accessId: data.accessId
                    });
                var chatdiv = document.createElement("div");
                if (qimo_config.m7webchatpage) {
                    if ((chatdiv = document.getElementById("web_chat_box")).innerHTML = this.chatboxstyle.html,
                        utils.isFromMobile()) {
                        var className = chatdiv.className;
                        className += " from_moblie",
                            chatdiv.className = className
                    }
                } else
                    chatdiv.innerHTML = this.chatboxstyle.html,
                        document.body.appendChild(chatdiv);
                var qimoFrame = document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0]
                    , href = utils.getCookie("href");
                "object" == ("undefined" == typeof qimoClientId ? "undefined" : _typeof(qimoClientId)) && !0 === qimoClientId.priority && (priority = !0),
                "object" == ("undefined" == typeof qimoClientId ? "undefined" : _typeof(qimoClientId)) && !0 === qimoClientId.showAnnexUrl && (showAnnexUrl = !0),
                utils.getBroswer() != utils.broswer.IE6 && utils.getBroswer() != utils.broswer.IE7 && (document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].src = qimo_config.chatPage + "?v=" + qimo_config.version + "&clientId=" + qimo_config.clientId + "&urlTitle=" + qimo_config.urlTitle + "&fromUrl=" + qimo_config.fromUrl + "&serviceStates=" + data.serviceStates + "&accessId=" + data.accessId + "&styleColor=" + data.cssStyle.styleColor + "&peers=" + encodeURIComponent(JSON.stringify(data.peers)) + "&sessionLastToPeer=" + qimo_config.sessionLastToPeer + "&otherParams=" + qimo_config.otherParams + "&seoSource=" + encodeURIComponent(seoSource) + "&seoKeywords=" + encodeURIComponent(seoKeywords) + "&xstKeywords=" + encodeURIComponent(xstKeywords) + "&companyName=" + encodeURIComponent(qimo_config.companyName) + "&seoUrl=" + encodeURIComponent(lastReferrer) + "&language=" + qimo_config.language + "&href=" + href + "&priority=" + priority + "&showAnnexUrl=" + showAnnexUrl + "&unionAccessId=" + qimo_config.unionAccessId),
                    this.loadStyle();
                var btn = document.getElementById("chatBtn");
                btn.style.display = "none",
                qimo_config.autoShow && "false" != qimo_config.autoShow || (btn.style.right = "-10000px",
                    btn.style.zIndex = "-100",
                    btn.style.display = "none",
                    isClick = !0);
                var chatBox = document.getElementById("qimo_chatpup")
                    , chatBoxParent = document.getElementById("web_chat_box")
                    , dragChatDom = document.getElementById("dragChat");
                document.getElementById("chatstyle");
                if (data.cssStyle.styleColor && null != data.cssStyle.styleColor && "undefined" != data.cssStyle.styleColor && (btn.style.backgroundColor = "#" + data.cssStyle.styleColor),
                data.scheduleEnable && data.entranceNode) {
                    var positionStyle = data.entranceNode.buttonStyle;
                    data.cssStyle.onlineText = positionStyle.text,
                        data.cssStyle.chatButtonLocation = positionStyle.location,
                        data.cssStyle.chatboxIconType = positionStyle.iconType,
                        "circle-left" == positionStyle.location || "circle-right" == positionStyle.location ? (data.cssStyle.chatButtonSideMargin = positionStyle.sideMargin,
                            data.cssStyle.chatButtonBottomMargin = positionStyle.bottomMargin) : "bottom-left" == positionStyle.location || "bottom-right" == positionStyle.location ? data.cssStyle.chatButtonSideMargin = positionStyle.sideMargin : "side-left" != positionStyle.location && "side-right" != positionStyle.location || (data.cssStyle.chatButtonBottomMargin = positionStyle.bottomMargin),
                    positionStyle.mobileBottomMargin && (data.cssStyle.chatButtonMobileBottomMargin = positionStyle.mobileBottomMargin),
                    void 0 !== positionStyle.mobileText && (data.cssStyle.onlineMobileText = positionStyle.mobileText),
                    positionStyle.mobileIconType && (data.cssStyle.chatboxMobileIconType = positionStyle.mobileIconType),
                    positionStyle.mobileLocation && (data.cssStyle.chatButtonMobileLocation = positionStyle.mobileLocation),
                    positionStyle.mobileSideMargin && (data.cssStyle.chatButtonMobileSideMargin = positionStyle.mobileSideMargin)
                }
                if (1 == data.serviceStates) {
                    var typeListHtml = "";
                    data.cssStyle.chatboxLocation ? utils.isFromMobile() && data.cssStyle.chatButtonMobileLocation ? btn.innerHTML = "<img width='25px' height='25px'  src='" + qimo_config.chatHost + "images/" + data.cssStyle.chatboxMobileIconType + ".png?1221'/><span>" + ("" == data.cssStyle.onlineMobileText.m7trim() ? "" : data.cssStyle.onlineMobileText) + "</span>" + typeListHtml + '<span id="qimo_badge"></span>' : btn.innerHTML = "<img width='25px' height='25px'  src='" + qimo_config.chatHost + "images/" + data.cssStyle.chatboxIconType + ".png?1221'/><span>" + ("" == data.cssStyle.onlineText.m7trim() ? "咨询客服" : data.cssStyle.onlineText) + "</span>" + typeListHtml + '<span id="qimo_badge"></span>' : btn.innerHTML = "<img width='28px' height='25px' style='margin:0px 5px -6px 0px;' src='" + qimo_config.chatHost + "images/chat.png'/><span>" + ("" == data.cssStyle.onlineText.trim() ? "咨询客服" : data.cssStyle.onlineText) + "</span>" + typeListHtml + '<span id="qimo_badge"></span>'
                } else
                    data.cssStyle.chatboxLocation ? btn.innerHTML = "<img width='25px' height='25px'  src='" + qimo_config.chatHost + "images/" + data.cssStyle.chatboxIconType + ".png?1221'/><span>" + ("" == data.cssStyle.offlineText.trim() ? "留言联系我们" : data.cssStyle.offlineText) + '</span><span id="qimo_badge"></span>' : btn.innerHTML = "<img width='28px' height='25px' style='margin:0px 5px -6px 0px;' src='" + qimo_config.chatHost + "images/chat.png'/><span>" + ("" == data.cssStyle.onlineText.trim() ? "咨询客服" : data.cssStyle.onlineText) + "</span>" + typeListHtml + '<span id="qimo_badge"></span>';
                if (utils.chatboxProp.isServiceTime = data.serviceStates,
                    styleColor = data.cssStyle.styleColor,
                    qimo_config.m7webchatpage)
                    chatBox.style.bottom = "auto",
                        chatBox.style.position = "unset";
                else if (data.cssStyle.chatboxLocation && data.advConfig && "common" != data.advConfig.windowType && !utils.isFromMobile()) {
                    var pos = [data.cssStyle.chatboxSideMargin, data.cssStyle.chatboxLocation];
                    chatBox = document.getElementById("qimo_chatpup");
                    "left" == pos[1] ? chatBox.style.left = pos[0] + "px" : "right" == pos[1] ? chatBox.style.right = pos[0] + "px" : "center" == pos[1] && (chatBox.style.left = "0",
                        chatBox.style.right = "0",
                        chatBox.style.margin = "0 auto")
                } else
                    chatBox.style.right = "18px";
                if (data.chatboxLocationY && data.advConfig && "common" != data.advConfig.windowType && !utils.isFromMobile()) {
                    pos = [data.chatboxSideMarginY, data.chatboxLocationY],
                        chatBox = document.getElementById("qimo_chatpup");
                    "top" == pos[1] ? chatBox.style.top = pos[0] + "px" : "bottom" == pos[1] ? chatBox.style.bottom = pos[0] + "px" : "center" == pos[1] && (chatBox.style.top = "0",
                        chatBox.style.bottom = "0",
                        chatBox.style.margin = "auto")
                }
                data.cssStyle.chatboxLocation && data.chatboxLocationY && data.advConfig && "common" != data.advConfig.windowType && !utils.isFromMobile() && "center" == data.chatboxLocationY && "center" == data.cssStyle.chatboxLocation && (chatBox.style.top = "0",
                    chatBox.style.bottom = "0",
                    chatBox.style.left = "0",
                    chatBox.style.right = "0",
                    chatBox.style.margin = "auto"),
                data.advConfig && "common" != data.advConfig.windowType && data.chatboxWidth && !utils.isFromMobile() && (chatBox.style.width = data.chatboxWidth + "px",
                qimo_config.m7webchatpage && chatBoxParent && (chatBoxParent.style.width = data.chatboxWidth + "px")),
                data.advConfig && "common" != data.advConfig.windowType && data.chatboxHeight && !utils.isFromMobile() && (chatBox.style.height = data.chatboxHeight + "px",
                qimo_config.m7webchatpage && chatBoxParent && (chatBoxParent.style.height = data.chatboxHeight + "px")),
                    self.chatMarginTopReset(),
                    chatBox.onmouseover = function(e) {
                        dragChatDom.style.display = "block"
                    }
                    ,
                    chatBox.onmouseout = function() {
                        dragChatDom.style.display = "none"
                    }
                    ,
                    this.loadAdvConfig(data),
                    utils.eventOn(btn, "click", this.openChat),
                utils.getBroswer() != utils.broswer.IE6 && utils.getBroswer() != utils.broswer.IE7 && qimoFrame.contentWindow.postMessage || (btn.style.display = "block");
                var msgBtn = document.getElementById("qimo_showNewMsg_box");
                utils.eventOn(msgBtn, "click", this.openChat);
                var closeBtn = document.getElementById("qimo_showNewMsg_close");
                utils.eventOn(closeBtn, "click", this.closeNewMsg),
                    callback(isClick)
            }
        }
        ,
        this.chatMarginTopReset = function() {
            if (utils.isFromMobile() && onlineData && onlineData.chatMarginTop && parseInt(onlineData.chatMarginTop)) {
                var iframeParent = document.getElementById("qimo_chatpup")
                    , iframeDiv = document.getElementById("chatIframe");
                iframeDiv.removeAttribute("height"),
                    iframeDiv.style.height = "calc(100% - " + parseInt(onlineData.chatMarginTop) + "px)",
                    iframeParent.style.marginTop = parseInt(onlineData.chatMarginTop) + "px"
            }
        }
        ,
        this.loadAdvConfig = function(data) {
            var chatBox = document.getElementById("qimo_chatpup")
                , chatBoxParent = document.getElementById("web_chat_box")
                , dragChatDom = document.getElementById("dragChat");
            if (data.advConfig && "common" === data.advConfig.windowType && !utils.isFromMobile()) {
                var davType = data.advConfig.advType;
                qimo_config.m7webchatpage ? (chatBox.removeChild(dragChatDom),
                    "1" == davType || "3" == davType ? chatBoxParent.style.width = "650px" : "2" == davType ? chatBoxParent.style.width = "820px" : "4" == davType && (chatBoxParent.style.width = "480px")) : this.startDrag(dragChatDom, chatBox, null, "qimo_chatpup"),
                    "1" == davType || "3" == davType ? (chatBox.style.width = "650px",
                        dragChatDom.style.width = "550px") : "2" == davType ? (chatBox.style.width = "820px",
                        dragChatDom.style.width = "720px") : "4" == davType && (chatBox.style.width = "480px",
                        dragChatDom.style.width = "380px")
            } else
                chatBox.removeChild(dragChatDom)
        }
        ,
        this.initInviteBox = function() {
            var self = this
                , inviteBoxDiv = document.createElement("div");
            inviteBoxDiv.innerHTML = this.inviteBoxStyle.html,
                document.body.appendChild(inviteBoxDiv);
            var qimo_invite_close_btn = document.getElementById("qimo_invite_close");
            qimo_invite_close_btn && utils.eventOn(qimo_invite_close_btn, "click", function() {
                document.getElementById("qimo_inviteBox").style.display = "none",
                "2" === onlineData.autoShowInviteType && qimosdk.autoInviteChat() && onlineData.closeStayTime && "0" !== onlineData.closeStayTime && (0 !== openTimeout && window.clearTimeout(openTimeout),
                    openTimeout = window.setTimeout(function() {
                        self.openInviteBox()
                    }, 1e3 * onlineData.closeStayTime)),
                "0" === onlineData.closeStayTime && utils.setCookie("close_stay", "1", "session")
            });
            var invite_click_button_1 = document.getElementById("invite_click_button_1")
                , invite_click_button_2 = document.getElementById("invite_click_button_2");
            utils.eventOn(invite_click_button_1, "click", this.inviteBoxOpenChat),
                utils.eventOn(invite_click_button_2, "click", this.inviteBoxHideInvite);
            var sendInviteContent_btn = document.getElementById("sendInviteContent");
            utils.eventOn(sendInviteContent_btn, "click", function() {
                document.getElementById("qimo_inviteBox").style.display = "none";
                var value = "";
                if ("" !== document.getElementById("sendInviteText").value)
                    if (value = document.getElementById("sendInviteText").value,
                    utils.getBroswer() == utils.broswer.IE8 && document.getElementById("sendInviteText").value === onlineData.inviteBoxData.inviteStyle.placeholder && (value = ""),
                    1 == utils.chatboxProp.isVisit && 0 == utils.chatboxProp.isChatBoxShow) {
                        if ("" !== document.getElementById("sendInviteText").value) {
                            var PostStashContent = "PostStashInviteBoxContent" + value;
                            document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage(PostStashContent, "*"),
                                document.getElementById("sendInviteText").value = ""
                        }
                    } else {
                        var stashContent = "stashInviteBoxContent" + value;
                        document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage(stashContent, "*"),
                            document.getElementById("sendInviteText").value = ""
                    }
                self.openChat()
            }),
            onlineData.inviteBoxData && this.loadInviteBoxStyle()
        }
        ,
        this.openInviteBox = function() {
            if (!utils.chatboxProp.isChatBoxShow) {
                var InviteBoxDom = document.getElementById("qimo_inviteBox");
                if (utils.getBroswer() == utils.broswer.IE8 && "" === document.getElementById("sendInviteText").value && (document.getElementById("sendInviteText").value = onlineData.inviteBoxData.inviteStyle.placeholder),
                    InviteBoxDom) {
                    if (utils.getCookie("close_stay"))
                        return;
                    InviteBoxDom.style.display = "block"
                }
            }
        }
        ,
        this.loadInviteBoxStyle = function() {
            var inviteBoxData = onlineData.inviteBoxData
                , inviteStyle = onlineData.inviteBoxData.inviteStyle
                , qimoInviteBoxDom = document.getElementById("qimo_inviteBox");
            if ("right" === inviteBoxData.positionX ? (qimoInviteBoxDom.style.left = "",
                qimoInviteBoxDom.style.right = inviteBoxData.distanceX + "px") : "left" === inviteBoxData.positionX ? (qimoInviteBoxDom.style.right = "",
                qimoInviteBoxDom.style.left = inviteBoxData.distanceX + "px") : "center" === inviteBoxData.positionX && (qimoInviteBoxDom.style.right = "0",
                qimoInviteBoxDom.style.left = "0"),
                "down" === inviteBoxData.positionY ? (qimoInviteBoxDom.style.top = "",
                    qimoInviteBoxDom.style.bottom = inviteBoxData.distanceY + "px") : "up" === inviteBoxData.positionY ? (qimoInviteBoxDom.style.bottom = "",
                    qimoInviteBoxDom.style.top = inviteBoxData.distanceY + "px") : "center" === inviteBoxData.positionY && (qimoInviteBoxDom.style.top = "0",
                    qimoInviteBoxDom.style.bottom = "0"),
            "2" === inviteStyle.layoutType && (document.getElementById("qimo_inviteBox_top_img").style.display = "none",
                document.getElementById("qimo_inviteBox_top_right").style.width = "100%",
                document.getElementById("qimo_inviteBox_top_right").style.marginLeft = "0"),
            "1" === inviteStyle.layoutType && inviteStyle.photourl && (document.getElementById("qimo_inviteBox_img").src = inviteStyle.photourl),
            void 0 !== inviteStyle.backImg && "" !== inviteStyle.backImg && (utils.getBroswer() == utils.broswer.IE8 ? (document.getElementById("qimo_inviteBox").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + inviteStyle.backImg + ", sizingMethod='scale')",
                document.getElementById("qimo_inviteBox").style.MsFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + inviteStyle.backImg + ", sizingMethod='scale')",
                document.getElementById("qimo_inviteBox").style.background = "url(" + inviteStyle.backImg + ") no-repeat\0/") : (document.getElementById("qimo_inviteBox").style.backgroundImage = "url(" + inviteStyle.backImg + ")",
                document.getElementById("qimo_inviteBox").style.backgroundSize = "cover")),
            !inviteStyle.backImg && inviteStyle.backColor && (document.getElementById("qimo_inviteBox").style.background = inviteStyle.backColor,
                document.getElementById("sendInviteContent").style.background = inviteStyle.backColor),
            inviteStyle.inviteWords && (document.getElementById("qimo_inviteBox_InviteWords").innerHTML = inviteStyle.inviteWords),
            utils.getBroswer() === utils.broswer.IE8 && (document.getElementById("sendInviteText").style.overflow = "auto"),
            inviteStyle.placeholder && (utils.getBroswer() == utils.broswer.IE8 ? (document.getElementById("sendInviteText").value = inviteStyle.placeholder,
                utils.eventOn(document.getElementById("sendInviteText"), "blur", function() {
                    "" === document.getElementById("sendInviteText").value && (document.getElementById("sendInviteText").value = inviteStyle.placeholder)
                }),
                utils.eventOn(document.getElementById("sendInviteText"), "focus", function() {
                    document.getElementById("sendInviteText").value === inviteStyle.placeholder && (document.getElementById("sendInviteText").value = "")
                })) : document.getElementById("sendInviteText").placeholder = inviteStyle.placeholder),
            inviteStyle.Buttons && 0 < inviteStyle.Buttons.length) {
                document.addEventListener ? (document.getElementById("invite_click_button_1").removeEventListener("click", this.inviteBoxOpenChat),
                    document.getElementById("invite_click_button_2").removeEventListener("click", this.inviteBoxHideInvite)) : (document.getElementById("invite_click_button_1").detachEvent("onclick", this.inviteBoxOpenChat),
                    document.getElementById("invite_click_button_2").detachEvent("onclick", this.inviteBoxHideInvite));
                for (var i = 0; i < inviteStyle.Buttons.length; i++) {
                    document.getElementById("invite_click_button_" + (i + 1)).innerHTML = inviteStyle.Buttons[i].text,
                        document.getElementById("invite_click_button_" + (i + 1)).style.color = inviteStyle.Buttons[i].color,
                        document.getElementById("invite_click_button_" + (i + 1)).style.borderColor = inviteStyle.Buttons[i].color;
                    var btn = document.getElementById("invite_click_button_" + (i + 1));
                    "openChat" === inviteStyle.Buttons[i].action ? utils.eventOn(btn, "click", this.inviteBoxOpenChat) : utils.eventOn(btn, "click", this.inviteBoxHideInvite)
                }
            }
            1 === inviteStyle.Buttons.length && (document.getElementById("invite_click_button_2").style.display = "none")
        }
        ,
        this.inviteBoxOpenChat = function() {
            document.getElementById("qimo_inviteBox").style.display = "none",
                self.openChat()
        }
        ,
        this.inviteBoxHideInvite = function() {
            document.getElementById("qimo_inviteBox").style.display = "none",
            "2" === onlineData.autoShowInviteType && qimosdk.autoInviteChat() && onlineData.closeStayTime && "0" !== onlineData.closeStayTime && (0 !== openTimeout && window.clearTimeout(openTimeout),
                openTimeout = window.setTimeout(function() {
                    self.openInviteBox()
                }, 1e3 * onlineData.closeStayTime))
        }
        ,
        this.loadStyle = function() {
            var style = document.createElement("link");
            (style.type = "text/css",
                style.rel = "stylesheet",
                utils.isFromMobile()) ? (style.href = qimo_config.chatHost + "/stylesheets/chatStyle_wap-7e9675f21c.css?v=" + qimo_config.version,
                document.getElementsByTagName("body")[0].setAttribute("data-7m", "7m_warp")) : style.href = qimo_config.chatHost + "/stylesheets/chatStyle-6da16ba661.css?v=" + qimo_config.version;
            document.getElementsByTagName("head")[0].appendChild(style)
        }
        ,
        this.closeNewMsg = function() {
            window.clearTimeout(showNewMsgTimeout),
                document.getElementById("qimo_showNewMsg_title").innerHTML = "",
                document.getElementById("qimo_showNewMsg_content").innerHTML = "",
                document.getElementById("qimo_showNewMsg").style.right = "-100%",
                document.getElementById("qimo_showNewMsg").style.left = "",
                document.getElementById("qimo_showNewMsg").style.display = "none",
                showNewMsgRight = -100
        }
        ,
        this.openChat = function() {
            if (self.chatMarginTopReset(),
                onlineData.scheduleEnable) {
                var data = {
                    accessId: qimo_config.accessId,
                    unionAccessId: qimo_config.unionAccessId,
                    location: encodeURIComponent(window.location.host),
                    referrer: document.referrer || "",
                    callbackF: "updateOnlineData",
                    action: "getOnlineStates"
                };
                self.loadJsonp(qimo_config.companyConfigUrl, data)
            } else
                openChatTodo()
        }
        ,
        window.updateOnlineData = function(c) {
            onlineData = c,
                openChatTodo(),
            window.qimo_autoReOpenFromCookie && utils.isFromMobile() && window.setTimeout(function() {
                qimosdk.hideChatBox(),
                    document.getElementById("qimo_chatpup").style.opacity = 1,
                    window.qimo_autoReOpenFromCookie = !1
            }, 500)
        }
    ;
    var openChatTodo = function() {
        if (utils.isFromMobile() && (utils.isIE(5) || utils.isIE(6) || utils.isIE(7) || utils.isIE(8)))
            window.alert("在线咨询不兼容当前浏览器版本, 请升级ie浏览器或使用其他浏览器");
        else if (utils.isIE(5) || utils.isIE(6) || utils.isIE(7))
            window.alert("在线咨询不兼容当前浏览器版本, 请升级ie浏览器或使用其他浏览器");
        else if (window.mobileHisPush && window.mobileHisPush(),
        !utils.isNewPageOpen() || qimo_config.m7webchatpage) {
            try {
                if ("string" == typeof qimoClientId && "undefined" != qimoClientId && (qimo_config.clientId = encodeURIComponent(qimoClientId)),
                "object" == ("undefined" == typeof qimoClientId ? "undefined" : _typeof(qimoClientId))) {
                    qimo_config.clientId = qimoClientId.userId || "";
                    str = "";
                    qimoClientId.customField && "object" == _typeof(qimoClientId.customField) ? (str = JSON.stringify(qimoClientId.customField),
                        strone = JSON.parse(str),
                        strNew = JSON.stringify(strone)) : qimoClientId.customField && "string" == typeof qimoClientId.customField && (strNew = qimoClientId.customField);
                    newClientId = utils.deepClone(qimoClientId);
                    strNew && (newClientId.customField = encodeURIComponent(strNew)),
                        qimo_config.otherParams = encodeURIComponent(JSON.stringify(newClientId))
                }
            } catch (e) {}
            document.getElementById("qimo_inviteBox") && "block" === document.getElementById("qimo_inviteBox").style.display && (document.getElementById("qimo_inviteBox").style.display = "none"),
            0 !== openTimeout && (window.clearTimeout(openTimeout),
                openTimeout = 0);
            var chatBox = document.getElementById("qimo_chatpup")
                , chatBtn = document.getElementById("chatBtn")
                , body = document.getElementsByTagName("body");
            if (window.pageScrollValue = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0,
            "7m_warp" === body[0].getAttribute("data-7m") && (body[0].setAttribute("data-7m", "overbody"),
                window.scrollTo(0, 0)),
            utils.isFromMobile() && (chatBox.style.left = "-8px",
                chatBox.style.top = "-8px"),
            1 == utils.chatboxProp.isVisit && 0 == utils.chatboxProp.isChatBoxShow)
                return chatBtn.style.display = "none",
                    chatBox.style.display = "block",
                    utils.chatboxProp.isChatBoxShow = 1,
                    document.getElementById("qimo_badge").style.display = "none",
                    utils.aniMove(chatBtn, {
                        bottom: -chatBtn.offsetHeight,
                        b: 0
                    }),
                0 < unreadMessageCount && document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("newMsgReOpen", "*"),
                    void (unreadMessageCount = 0);
            if (1 != utils.chatboxProp.isVisit || 1 != utils.chatboxProp.isChatBoxShow) {
                if (utils.getBroswer() != utils.broswer.IE6 && utils.getBroswer() != utils.broswer.IE7) {
                    utils.chatboxProp.isVisit = 1,
                        utils.chatboxProp.isChatBoxShow = 1;
                    var getCss = function(o, key) {
                        return o.currentStyle ? o.currentStyle[key] : document.defaultView.getComputedStyle(o, !1)[key]
                    };
                    if (("auto" === getCss(chatBox, "bottom") || parseInt(getCss(chatBox, "bottom")) <= 0) && "auto" != chatBox.style.margin ? utils.aniMove(chatBox, {
                        bottom: 0,
                        b: -chatBox.offsetHeight
                    }) : onlineData.advConfig && "common" == onlineData.advConfig.windowType && utils.aniMove(chatBox, {
                        bottom: 0,
                        b: -chatBox.offsetHeight
                    }),
                        chatBox.style.display = "block",
                        chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage) {
                        chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("qimoClientId_" + (qimo_config.clientId || ""), "*"),
                            chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("qimoClientOtherParams_" + (qimo_config.otherParams || ""), "*");
                        var onlineDataNew = JSON.stringify(onlineData)
                            , parentSidkey = "parent_qimo_sid_" + qimo_config.accessId
                            , parentSid = utils.getCookie(parentSidkey) || void 0;
                        parentSid && chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("m7chat_parent_sid" + parentSid, "*");
                        var talkingKey = "qimo_talking_" + qimo_config.accessId
                            , talkingStatus = utils.getCookie(talkingKey);
                        window.qimo_autoReOpenFromCookie && talkingStatus && chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("qimo_talking_open", "*"),
                            chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("m7chat_open_" + (onlineDataNew || ""), "*"),
                        "object" === ("undefined" == typeof m7CardInfo ? "undefined" : _typeof(m7CardInfo)) && chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("m7CardInfo_" + (JSON.stringify(m7CardInfo) || ""), "*"),
                        "object" === ("undefined" == typeof m7ProductInfo ? "undefined" : _typeof(m7ProductInfo)) && chatBox.getElementsByTagName("iframe")[0].contentWindow.postMessage("m7ProductInfo_" + (JSON.stringify(m7ProductInfo) || ""), "*")
                    } else {
                        (chatWin = window.open(qimo_config.chatPage + "?v=" + qimo_config.version + "&clientId=" + (qimo_config.clientId || "") + "&urlTitle=" + qimo_config.urlTitle + "&fromUrl=" + qimo_config.fromUrl + "&serviceStates=" + utils.chatboxProp.isServiceTime + "&newWin=true&accessId=" + qimo_config.accessId + "&styleColor=" + styleColor + "&peers=" + encodeURIComponent(JSON.stringify(peers)) + "&sessionLastToPeer=" + qimo_config.sessionLastToPeer + "&otherParams=" + qimo_config.otherParams + "&seoSource=" + encodeURIComponent(seoSource) + "&seoKeywords=" + encodeURIComponent(seoKeywords) + "&xstKeywords=" + encodeURIComponent(xstKeywords) + "&seoUrl=" + encodeURIComponent(lastReferrer) + "&utm_source=" + encodeURIComponent(utm_source) + "&utm_medium=" + encodeURIComponent(utm_medium) + "&utm_term=" + encodeURIComponent(utm_term) + "&utm_content=" + encodeURIComponent(utm_content) + "&utm_campaign=" + encodeURIComponent(utm_campaign) + "&priority=" + priority + "&showAnnexUrl=" + showAnnexUrl + "&companyName=" + encodeURIComponent(qimo_config.companyName) + "&unionAccessId=" + qimo_config.unionAccessId, "chatWin", "width=380px,height=535px,toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no")).focus()
                    }
                    chatBtn.style.display = "none",
                        utils.aniMove(chatBtn, {
                            bottom: -chatBtn.offsetHeight,
                            b: parseFloat(chatBtn.style.bottom.split("px")[0])
                        })
                } else {
                    var chatWin;
                    (chatWin = window.open(qimo_config.chatPage + "?v=" + qimo_config.version + "&clientId=" + (qimo_config.clientId || "") + "&urlTitle=" + qimo_config.urlTitle + "&fromUrl=" + qimo_config.fromUrl + "&serviceStates=" + utils.chatboxProp.isServiceTime + "&newWin=true&accessId=" + qimo_config.accessId + "&styleColor=" + styleColor + "&peers=" + encodeURIComponent(JSON.stringify(peers)) + "&sessionLastToPeer=" + qimo_config.sessionLastToPeer + "&otherParams=" + qimo_config.otherParams + "&seoSource=" + encodeURIComponent(seoSource) + "&seoKeywords=" + encodeURIComponent(seoKeywords) + "&xstKeywords=" + encodeURIComponent(xstKeywords) + "&seoUrl=" + encodeURIComponent(lastReferrer) + "&utm_source=" + encodeURIComponent(utm_source) + "&utm_medium=" + encodeURIComponent(utm_medium) + "&utm_term=" + encodeURIComponent(utm_term) + "&utm_content=" + encodeURIComponent(utm_content) + "&utm_campaign=" + encodeURIComponent(utm_campaign) + "&priority=" + priority + "&showAnnexUrl=" + showAnnexUrl + "&companyName=" + encodeURIComponent(qimo_config.companyName) + "&unionAccessId=" + qimo_config.unionAccessId, "chatWin", "width=380px,height=535px,toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no")) && chatWin.focus()
                }
                "function" == typeof moorOpenChat && moorOpenChat()
            }
        } else {
            var seoData = {};
            seoData["qimo_chat_referrer_" + qimo_config.accessId] = document.referrer,
                utils.setCookie(seoData, "", 1 / 48);
            var newPageOtherParams, newPageClientId = "", newPageCustomField = "", newClientId = {};
            try {
                if ("string" == typeof qimoClientId && "undefined" != qimoClientId && (newPageClientId = encodeURIComponent(qimoClientId)),
                "object" == ("undefined" == typeof qimoClientId ? "undefined" : _typeof(qimoClientId))) {
                    newPageClientId = qimoClientId.userId || "";
                    var strone, strNew, str = "";
                    qimoClientId.customField && "object" == _typeof(qimoClientId.customField) ? (str = JSON.stringify(qimoClientId.customField),
                        strone = JSON.parse(str),
                        strNew = JSON.stringify(strone)) : qimoClientId.customField && "string" == typeof qimoClientId.customField && (strNew = qimoClientId.customField),
                        newClientId = utils.deepClone(qimoClientId),
                    strNew && (newClientId.customField = encodeURIComponent(strNew)),
                        qimo_config.otherParams = encodeURIComponent(JSON.stringify(newClientId)),
                        newPageCustomField = newClientId.customField
                }
            } catch (e) {}
            "object" === ("undefined" == typeof m7CardInfo ? "undefined" : _typeof(m7CardInfo)) && (newClientId.cardInfo = m7CardInfo),
            "object" === ("undefined" == typeof m7ProductInfo ? "undefined" : _typeof(m7ProductInfo)) && (newClientId.m7ProductInfo = m7ProductInfo),
                newPageOtherParams = encodeURIComponent(JSON.stringify(newClientId));
            var newPage = qimo_config.chatHost + "pcwebchat.html?accessId=" + qimo_config.accessId + "&urlTitle=" + qimo_config.urlTitle + "&fromUrl=" + qimo_config.fromUrl + "&language=" + qimo_config.language + "&otherParams=" + newPageOtherParams + "&clientId=" + newPageClientId + "&unionAccessId=" + qimo_config.unionAccessId + "&customField=" + newPageCustomField + "&showAnnexUrl=" + showAnnexUrl + "&priority=" + priority;
            window.open(newPage)
        }
    };
    this.hideChatBox = function(isPush) {
        window.mobileBackFunc && window.mobileBackFunc(isPush),
            utils.chatboxProp.isChatBoxShow = 0;
        var chatBox = document.getElementById("qimo_chatpup")
            , chatBtn = document.getElementById("chatBtn")
            , body = document.getElementsByTagName("body");
        if (chatBox.style.display = "none",
        "overbody" === body[0].getAttribute("data-7m") && body[0].setAttribute("data-7m", "7m_warp"),
        window.pageScrollValue && 0 < window.pageScrollValue && utils.isFromMobile() && window.scroll(0, window.pageScrollValue),
        qimo_config.autoShow && "false" != qimo_config.autoShow) {
            chatBtn.style.display = "block",
                utils.chatBtnPosition();
            var bpos = parseFloat(chatBtn.style.bottom.split("px")[0]);
            chatBtn.style.bottom = -chatBtn.offsetHeight + "px",
                utils.aniMove(chatBtn, {
                    bottom: bpos,
                    b: -chatBtn.offsetHeight
                }, null, function() {})
        } else
            chatBtn.style.right = "-10000px",
                chatBtn.style.zIndex = "-100",
                chatBtn.style.display = "none"
    }
        ,
        this.closeChatBox = function() {
            window.mobileBackFunc && window.mobileBackFunc(!1);
            var chatBox = document.getElementById("qimo_chatpup")
                , chatBtn = document.getElementById("chatBtn")
                , body = document.getElementsByTagName("body");
            if (chatBox.style.display = "none",
            "overbody" === body[0].getAttribute("data-7m") && body[0].setAttribute("data-7m", "7m_warp"),
            window.pageScrollValue && 0 < window.pageScrollValue && utils.isFromMobile() && window.scroll(0, window.pageScrollValue),
            qimo_config.autoShow && "false" != qimo_config.autoShow) {
                chatBtn.style.display = "block",
                    utils.chatBtnPosition();
                var bpos = parseFloat(chatBtn.style.bottom.split("px")[0]);
                chatBtn.style.bottom = -chatBtn.offsetHeight + "px",
                    utils.aniMove(chatBtn, {
                        bottom: bpos,
                        b: -chatBtn.offsetHeight
                    })
            } else
                chatBtn.style.right = "-10000px",
                    chatBtn.style.zIndex = "-100",
                    chatBtn.style.display = "none";
            utils.chatboxProp.isChatBoxShow = 0,
                utils.chatboxProp.isVisit = 0
        }
        ,
        this.validateEmebedState = function(accessId, location) {
            var data = {
                accessId: accessId,
                location: encodeURIComponent(location),
                action: "validateEmebedState",
                callbackF: "validateEmebedState"
            };
            this.loadJsonp(qimo_config.companyConfigUrl, data)
        }
        ,
        this.videoboxstyle = {
            html: "<div class='qimo_videopup' id='qimo_videopup' style='display: none'><div style='' class='m7_dragbar' id='drag'><div class='qimo_minimg' id='qimo_minimg'><img src='" + qimo_config.chatHost + "images/small.png'></div><div class='qimo_maximg' id='qimo_maximg' style='display: none'><img src='" + qimo_config.chatHost + "images/big.png' ></img></div> </div><div id='mask'></div><div id='m7videoIframe'  style=' height: 100%; width: 100%;'></div></div>"
        },
        this.screenboxstyle = {
            html: "<div class='qimo_screenpop' id='qimo_screenpop' style='display: none'><div class='screendragbar' id='screendrag'></div><div class='qimo_headerimg' id='qimo_headerimg'><div class='screenminimg' style='display: none'  id='screenminimg'><img src='" + qimo_config.chatHost + "images/small.png'></div><div class='screenminimg' id='screenmaximg'><img src='" + qimo_config.chatHost + "images/big.png'></div><div class='screenminimg' id='screencloseimg'><img src='" + qimo_config.chatHost + "images/close.png' style='width: 16px;height: 16px;'></div></div> <div id='mask'></div><iframe id='screenIframe' src='' height='100%' width='100%' allow='microphone; camera'></iframe></div>"
        },
        this.userBehaviorPlaybackInit = function(api, siteId) {
            var el = document.createElement("script");
            el.setAttribute("charset", "UTF-8"),
                el.src = qimo_config.chatHost + "javascripts/clack.min.js?v=" + qimo_config.version;
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(el, s),
                el.onload = el.onreadystatechange = function() {
                    var rec = new clack.Recorder({
                        base: window.location.origin,
                        url: window.location.href,
                        pageScrollHeight: window.document.body.scrollHeight + "_" + window.document.body.clientHeight,
                        api: api,
                        wid: siteId
                    });
                    document.documentElement.addEventListener("clacksession", function(data) {
                        var result = JSON.parse(data.detail)
                            , iframe = document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0];
                        result && iframe.contentWindow.postMessage("userBehaviorVideoId_" + result.session, "*")
                    }, !1),
                        rec.startRecording()
                }
        }
        ,
        this.initVideo = function() {
            var videodiv = document.createElement("div");
            videodiv.innerHTML = this.videoboxstyle.html,
                document.body.appendChild(videodiv);
            var videoDom = document.getElementById("qimo_videopup")
                , dragDom = document.getElementById("drag");
            if (!utils.isFromMobile()) {
                var minimg = document.getElementById("qimo_minimg")
                    , maximg = document.getElementById("qimo_maximg");
                minimg.addEventListener("click", function() {
                    var iframe = document.getElementById("qimo_videopup").getElementsByTagName("iframe")[0];
                    self.closeTip || (self.mini = !0,
                        minimg.style.display = "none",
                        maximg.style.display = "block",
                        videoDom.style.width = "350px",
                        videoDom.style.height = "250px",
                        videoDom.style.left = "60%",
                        videoDom.style.top = "44%",
                        iframe.contentWindow.postMessage("smallMode", "*"))
                }),
                    maximg.addEventListener("click", function() {
                        var iframe = document.getElementById("qimo_videopup").getElementsByTagName("iframe")[0];
                        self.mini = !1,
                            minimg.style.display = "block",
                            maximg.style.display = "none",
                            videoDom.style.width = "700px",
                            videoDom.style.height = "500px",
                            videoDom.style.left = "35%",
                            videoDom.style.top = "20%",
                            iframe.contentWindow.postMessage("bigMode", "*")
                    })
            }
            videoDom.onmouseover = function(e) {
                dragDom.style.display = "block"
            }
                ,
                videoDom.onmouseout = function() {
                    dragDom.style.display = "none"
                }
                ,
                this.startDrag(dragDom, videoDom)
        }
        ,
        this.initScreen = function() {
            var screendiv = document.createElement("div");
            screendiv.innerHTML = this.screenboxstyle.html,
                document.body.appendChild(screendiv);
            var iframe = document.getElementById("qimo_screenpop").getElementsByTagName("iframe")[0]
                , screenDom = document.getElementById("qimo_screenpop")
                , headerDom = document.getElementById("qimo_headerimg")
                , dragDom = document.getElementById("screendrag")
                , screenminimg = document.getElementById("screenminimg")
                , screenmaximg = document.getElementById("screenmaximg")
                , screencloseimg = document.getElementById("screencloseimg");
            screenminimg.addEventListener("click", function() {
                self.closeTip || (self.mini = !0,
                    screenminimg.style.display = "none",
                    screenmaximg.style.display = "inline-block",
                    screenDom.style.width = "700px",
                    screenDom.style.height = "400px",
                    screenDom.style.left = "28%",
                    screenDom.style.top = "20%")
            }),
                screenmaximg.addEventListener("click", function() {
                    var clientHeight = window.innerHeight
                        , clientWidth = window.innerWidth;
                    self.mini = !1,
                        screenminimg.style.display = "inline-block",
                        screenmaximg.style.display = "none",
                        screenDom.style.width = clientWidth + "px",
                        screenDom.style.height = clientHeight + "px",
                        screenDom.style.left = "0",
                        screenDom.style.top = "0"
                }),
                screencloseimg.addEventListener("click", function() {
                    iframe.contentWindow.postMessage("wantClose", "*")
                }),
                screenDom.onmouseover = function(e) {
                    dragDom.style.display = "block",
                        headerDom.style.display = "block"
                }
                ,
                screenDom.onmouseout = function() {
                    dragDom.style.display = "none",
                        headerDom.style.display = "none"
                }
                ,
                this.startDrag(dragDom, screenDom)
        }
        ,
        this.startDrag = function(bar, target, callback, currentDom) {
            var drawparams = {
                left: 0,
                top: 0,
                right: 0,
                bottom: 0,
                currentX: 0,
                currentY: 0,
                flag: !1
            }
                , clientWidth = document.documentElement.clientWidth
                , clientHeight = document.documentElement.clientHeight
                , getCss = function(o, key) {
                return o.currentStyle ? o.currentStyle[key] : document.defaultView.getComputedStyle(o, !1)[key]
            }
                , ieFlag = !1;
            if (utils.isFromMobile() && "chatBtn" === bar.id) {
                var maxW = document.documentElement.clientWidth - bar.offsetWidth
                    , maxH = document.documentElement.clientHeight - bar.offsetHeight
                    , oL = 0
                    , oT = 0;
                bar.addEventListener("touchstart", function(e) {
                    if ($(event.target).length) {
                        var touch = (e || window.event).targetTouches[0];
                        oL = touch.clientX - bar.offsetLeft,
                            oT = touch.clientY - bar.offsetTop,
                            document.addEventListener("touchmove", bar, !1)
                    }
                }),
                    bar.addEventListener("touchmove", function(e) {
                        e.preventDefault();
                        var touch = (e || window.event).targetTouches[0]
                            , oLeft = touch.clientX - oL
                            , oTop = touch.clientY - oT;
                        oLeft < 0 ? oLeft = 0 : maxW <= oLeft && (oLeft = maxW),
                            oTop < 0 ? oTop = 0 : maxH <= oTop && (oTop = maxH),
                            bar.style.left = oLeft + "px",
                            bar.style.top = oTop + "px"
                    })
            } else
                bar.onmousedown = function(event) {
                    window.onresize = function() {
                        clientWidth = document.documentElement.clientWidth,
                            clientHeight = document.documentElement.clientHeight
                    }
                        ,
                        "auto" !== getCss(target, "left") ? getCss(target, "left") < 1 ? drawparams.left = getCss(target, "left") * clientWidth : drawparams.left = getCss(target, "left") : "auto" !== getCss(target, "right") && (getCss(target, "right") < 1 ? drawparams.right = getCss(target, "right") * clientWidth : drawparams.left = getCss(target, "right"),
                            ieFlag = !0,
                            drawparams.left = target.offsetLeft),
                        "auto" !== getCss(target, "top") ? getCss(target, "top") < 1 ? drawparams.top = getCss(target, "top") * clientHeight : drawparams.top = getCss(target, "top") : "auto" !== getCss(target, "bottom") && (getCss(target, "bottom") < 1 ? drawparams.bottom = getCss(target, "bottom") * clientHeight : drawparams.bottom = getCss(target, "bottom"),
                            ieFlag = !0,
                            drawparams.top = target.offsetTop),
                        document.getElementById("mask").style.display = "block",
                        document.getElementById("maskChat").style.display = "block",
                        drawparams.flag = !0,
                    event || (event = window.event,
                            bar.onselectstart = function() {
                                return !1
                            }
                    );
                    var e = event;
                    drawparams.currentX = e.clientX,
                        drawparams.currentY = e.clientY,
                        document.onmouseup = function() {
                            document.getElementById("mask").style.display = "none",
                                document.getElementById("maskChat").style.display = "none",
                                drawparams.flag = !1
                        }
                        ,
                        document.onmousemove = function(event) {
                            var e = event || window.event;
                            if (drawparams.flag) {
                                var nowX = e.clientX
                                    , nowY = e.clientY
                                    , disX = nowX - drawparams.currentX
                                    , disY = nowY - drawparams.currentY;
                                if ("qimo_chatpup" === currentDom) {
                                    var boxWidth = document.getElementById("qimo_chatpup").clientWidth
                                        , boxHeight = document.getElementById("qimo_chatpup").clientHeight
                                        , limitLeft = parseInt(drawparams.left) + disX > clientWidth - boxWidth - 2 ? clientWidth - boxWidth - 2 : parseInt(drawparams.left) + disX < 100 - boxWidth ? 100 - boxWidth : parseInt(drawparams.left) + disX
                                        , limitTop = parseInt(drawparams.top) + disY > clientHeight - boxHeight - 2 ? clientHeight - boxHeight - 2 : parseInt(drawparams.top) + disY < 100 - boxHeight ? 100 - boxHeight : parseInt(drawparams.top) + disY;
                                    ieFlag ? (target.style.left = parseInt(drawparams.left) + disX + "px",
                                        target.style.top = parseInt(drawparams.top) + disY + "px",
                                        ieFlag = !1) : (target.style.left = limitLeft <= 0 ? "0px" : limitLeft + "px",
                                        target.style.top = limitTop <= 0 ? "0px" : limitTop + "px")
                                } else
                                    target.style.left = parseInt(drawparams.left) + disX + "px",
                                        target.style.top = parseInt(drawparams.top) + disY + "px"
                            }
                            "function" == typeof callback && callback(parseInt(drawparams.left) + disX, parseInt(drawparams.top) + disY)
                        }
                }
        }
    ;
    var qimoVideoApi = null
        , qimoVideoCustJoin = null;
    this.openVideo = function(vedioMsg) {
        for (var m7video = document.getElementById("m7videoIframe"); m7video.hasChildNodes(); )
            m7video.removeChild(m7video.firstChild);
        var isSafari = !1;
        if (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && (isSafari = !0),
        checkCodecsSupported() || isSafari) {
            var videoDom = document.getElementById("qimo_videopup")
                , chatIframe = document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow;
            try {
                var configOverwrite = _defineProperty({
                    startWithAudioMuted: !1,
                    startWithVideoMuted: "video" !== vedioMsg.videoType,
                    transcribingEnabled: !1,
                    requireDisplayName: !1,
                    enableWelcomePage: !0,
                    enableClosePage: !1,
                    resolution: 720,
                    constraints: {
                        video: {
                            height: {
                                ideal: 720,
                                max: 720,
                                min: 180
                            },
                            width: {
                                ideal: 1280,
                                max: 1280,
                                min: 320
                            }
                        },
                        p2p: {
                            enabled: !1,
                            preferH264: !0,
                            disableH264: !1,
                            useStunTurn: !1
                        },
                        useStunTurn: !0,
                        useTurnUdp: !1
                    },
                    disableRemoteMute: !0,
                    disable1On1Mode: !0
                }, "disableRemoteMute", !0)
                    , options = {
                    roomName: vedioMsg.roomId,
                    height: "100%",
                    parentNode: document.querySelector("#m7videoIframe"),
                    interfaceConfigOverwrite: {
                        TOOLBAR_BUTTONS: ["microphone", "camera", "desktop", "fullscreen", "fodeviceselection", "hangup", "settings", "videoquality"],
                        SETTINGS_SECTIONS: ["devices", "language"]
                    },
                    configOverwrite: configOverwrite
                };
                qimoVideoApi = new JitsiMeetExternalAPI("kfvideo.7moor.com",options),
                    videoDom.style.display = "block",
                    qimoVideoApi.executeCommand("subject", " "),
                    qimoVideoApi.addEventListener("participantRoleChanged", function(event) {
                        "moderator" === event.role && qimoVideoApi.executeCommand("password", vedioMsg.password)
                    }),
                    qimoVideoApi.on("passwordRequired", function() {
                        qimoVideoApi.executeCommand("password", vedioMsg.password)
                    }),
                    qimoVideoApi.addEventListener("readyToClose", function(event) {
                        1 < qimoVideoApi.getNumberOfParticipants() || qimoVideoCustJoin ? chatIframe.postMessage("UserHangup", "*") : chatIframe.postMessage("UserCancel", "*"),
                            qimoVideoCustJoin = !1,
                            qimosdk.CloseVideo()
                    }),
                    qimoVideoApi.addEventListener("participantLeft", function(event) {}),
                    qimoVideoApi.addEventListener("videoConferenceJoined", function(event) {
                        qimoVideoApi.executeCommand("avatarUrl", " "),
                            qimoVideoApi.executeCommand("displayName", "访客")
                    }),
                    qimoVideoApi.addEventListener("participantJoined", function(event) {
                        event && event.id && (qimoVideoCustJoin = !0)
                    })
            } catch (error) {
                console.error("Failed to load Jitsi API", error)
            }
        } else
            alert("请升级你的浏览器！"),
                qimosdk.CloseVideo(),
                chatIframe.postMessage("notSupportinvited", "*")
    }
        ,
        this.CloseVideo = function() {
            var videoDom = document.getElementById("qimo_videopup");
            if (this.mini = !1,
            qimoVideoApi && qimoVideoApi.dispose(),
                qimoVideoApi = null,
                videoDom.style.display = "none",
                !utils.isFromMobile()) {
                var minimg = document.getElementById("qimo_minimg")
                    , maximg = document.getElementById("qimo_maximg");
                minimg.style.display = "block",
                    maximg.style.display = "none",
                    videoDom.style.width = "700px",
                    videoDom.style.height = "500px",
                    videoDom.style.left = "35%",
                    videoDom.style.top = "20%"
            }
            for (var m7video = document.getElementById("m7videoIframe"); m7video.hasChildNodes(); )
                m7video.removeChild(m7video.firstChild)
        }
        ,
        this.openShareScreen = function(screenmsg) {
            var screenDom = document.getElementById("qimo_screenpop")
                , iframe = document.getElementById("qimo_screenpop").getElementsByTagName("iframe")[0];
            screenDom.style.display = "block",
                iframe.src = qimo_config.screenSharePage + "/?type=join&roomid=" + screenmsg.roomid + "&agentName=" + screenmsg.kefuname
        }
        ,
        this.closeShareScreen = function() {
            var screenDom = document.getElementById("qimo_screenpop")
                , iframe = document.getElementById("qimo_screenpop").getElementsByTagName("iframe")[0]
                , screenminimg = document.getElementById("screenminimg")
                , screenmaximg = document.getElementById("screenmaximg");
            screenminimg.style.display = "none",
                screenmaximg.style.display = "inline-block",
                screenDom.style.display = "none",
                screenDom.style.width = "700px",
                screenDom.style.height = "400px",
                screenDom.style.left = "35%",
                screenDom.style.top = "20%",
                this.mini = !1,
                iframe.src = ""
        }
        ,
        this.m7showNewMsg = function(newMsg) {
            var newcontent, chatBox = document.getElementById("qimo_chatpup"), chatBtn = document.getElementById("chatBtn");
            if (utils.isFromMobile() || "true" === qimo_config.newMsgNotPop)
                1 == utils.chatboxProp.isVisit && 0 == utils.chatboxProp.isChatBoxShow && (0 !== showNewMsgTimeout && (window.clearTimeout(showNewMsgTimeout),
                    document.getElementById("qimo_showNewMsg_title").innerHTML = "",
                    document.getElementById("qimo_showNewMsg_content").innerHTML = "",
                    document.getElementById("qimo_showNewMsg").style.right = "-100%",
                    document.getElementById("qimo_showNewMsg").style.left = "",
                    document.getElementById("qimo_showNewMsg").style.display = "none",
                    showNewMsgRight = -100),
                "text" === newMsg.contentType && (newcontent = newMsg.content) && 100 < newcontent.length && (newcontent = newcontent.slice(0, 100) + "..."),
                "image" === newMsg.contentType && (newcontent = "[图片]"),
                "file" === newMsg.contentType && (newcontent = "[文件]"),
                "screenShare" === newMsg.contentType && (newcontent = "[屏幕共享消息]"),
                "iframe" !== newMsg.contentType && "richText" !== newMsg.contentType || (newcontent = "[链接消息]"),
                "video" === newMsg.contentType && (newcontent = "[视频消息]"),
                "evaluation" === newMsg.contentType && (newcontent = "[请您评价]"),
                "sessionForm" === newMsg.contentType && (newcontent = "[表单消息]"),
                newMsg.user && "undefined" != newMsg.user || (newMsg.user = "系统消息"),
                    document.getElementById("qimo_showNewMsg_title").innerHTML = newMsg.user,
                    document.getElementById("qimo_showNewMsg_content").innerHTML = newcontent,
                    document.getElementById("qimo_showNewMsg").style.display = "block",
                    requestAnimationFrame(qimosdk.showNewMsgAnimation),
                    showNewMsgTimeout = window.setTimeout(function() {
                        document.getElementById("qimo_showNewMsg_title").innerHTML = "",
                            document.getElementById("qimo_showNewMsg_content").innerHTML = "",
                            document.getElementById("qimo_showNewMsg").style.right = "-100%",
                            document.getElementById("qimo_showNewMsg").style.left = "",
                            document.getElementById("qimo_showNewMsg").style.display = "none",
                            showNewMsgRight = -100
                    }, 3e3));
            else if (1 == utils.chatboxProp.isVisit && 0 == utils.chatboxProp.isChatBoxShow)
                return chatBtn.style.display = "none",
                    chatBox.style.display = "block",
                    utils.chatboxProp.isChatBoxShow = 1,
                    document.getElementById("qimo_badge").style.display = "none",
                    unreadMessageCount = 0,
                    utils.aniMove(chatBtn, {
                        bottom: -chatBtn.offsetHeight,
                        b: 0
                    }),
                document.getElementById("qimo_inviteBox") && "block" === document.getElementById("qimo_inviteBox").style.display && (document.getElementById("qimo_inviteBox").style.display = "none"),
                0 !== openTimeout && (window.clearTimeout(openTimeout),
                    openTimeout = 0),
                    void document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("newMsgReOpen", "*")
        }
        ,
        this.showNewMsgAnimation = function() {
            showNewMsgRight += 10,
                document.getElementById("qimo_showNewMsg").style.right = showNewMsgRight + "%",
                showNewMsgRight < -1 ? requestAnimationFrame(qimosdk.showNewMsgAnimation) : document.getElementById("qimo_showNewMsg").style.left = 0
        }
        ,
        this.autoInviteChat = function() {
            if ("1" !== onlineData.autoInvite || utils.isNewPageOpen())
                return !1;
            var mobile = onlineData.autoInviteMobile
                , pc = onlineData.autoInvitePC
                , fromMobile = utils.isFromMobile()
                , flag = !0;
            if (flag = !!(void 0 === mobile && void 0 === pc || mobile && fromMobile || pc && !fromMobile),
            !utils.getCookie("close_stay") && flag) {
                var dataObj = onlineData.autoInviteData;
                if (!(dataObj.special && dataObj.specialTime.length || dataObj.usuallyTime.length))
                    return !0;
                var date = utils.getCurrentDateDay()
                    , currentTime = utils.getCurrentDateTime()
                    , specialFlag = !1;
                if (dataObj.special && dataObj.specialTime.length)
                    for (var na = 0; na < dataObj.specialTime.length; na++) {
                        var temp = dataObj.specialTime[na].data;
                        if (date >= temp.day[0] && date <= temp.day[1])
                            for (var i = 0; i < temp.workTime.length; i++)
                                if (currentTime >= temp.workTime[i].start && currentTime <= temp.workTime[i].end) {
                                    specialFlag = !0;
                                    break
                                }
                    }
                var usuallyFlag = !1;
                if (dataObj.usuallyTime && dataObj.usuallyTime.length && !specialFlag)
                    for (var nb = 0; nb < dataObj.usuallyTime.length; nb++) {
                        var item = dataObj.usuallyTime[nb].data
                            , currendDay = (date = new Date).getDay();
                        if (7 === currendDay ? currendDay = 1 : currendDay += 1,
                        -1 < item.weekDayId.join("").indexOf(currendDay + ""))
                            for (i = 0; i < item.workTime.length; i++)
                                if (currentTime >= item.workTime[i].start && currentTime <= item.workTime[i].end) {
                                    usuallyFlag = !0;
                                    break
                                }
                    }
                return !(specialFlag || !specialFlag && !usuallyFlag) && (!!usuallyFlag || void 0)
            }
        }
        ,
        this.reInitChat = function(data) {
            utils.chatboxProp.isChatBoxShow = 0,
                utils.chatboxProp.isServiceTime = 0,
                utils.chatboxProp.isVisit = 0,
                peers = void 0,
            (unreadMessageCount = 0) !== showNewMsgTimeout && window.clearTimeout(showNewMsgTimeout),
            0 !== openTimeout && window.clearTimeout(openTimeout),
            document.getElementById("chatBtn") && document.getElementById("chatBtn").parentNode && document.getElementById("chatBtn").parentNode.removeChild(document.getElementById("chatBtn")),
            document.getElementById("qimo_chatpup") && document.getElementById("qimo_chatpup").parentNode && document.getElementById("qimo_chatpup").parentNode.removeChild(document.getElementById("qimo_chatpup")),
            document.getElementById("qimo_showNewMsg") && document.getElementById("qimo_showNewMsg").parentNode && document.getElementById("qimo_showNewMsg").parentNode.removeChild(document.getElementById("qimo_showNewMsg")),
                this.initChat(data, function(data) {
                    window.qimosdk.afterInit()
                })
        }
        ,
        this.reInit = function(obj, callback) {
            qimo_config.accessId = obj.accessId ? obj.accessId : void 0,
                qimo_config.unionAccessId = obj.unionAccessId ? obj.unionAccessId : void 0,
            obj.otherParams && (qimo_config.otherParams = obj.otherParams),
            obj.clientId && ("string" == typeof obj.clientId && "undefined" != obj.clientId && (qimo_config.clientId = encodeURIComponent(obj.clientId)),
            "object" == _typeof(obj.clientId) && (qimo_config.clientId = obj.clientId.userId || "")),
            "function" == typeof callback && (qimo_config.reInitCallback = callback),
                window.m7InitConfigure.init()
        }
        ,
        this.afterInit = function() {
            if (utils.isIE(5) || utils.isIE(6) || utils.isIE(7)) {
                qimo_loaded = !0,
                    window.qimoChatLoaded = !0;
                var btn = document.getElementById("chatBtn")
                    , bpos = utils.chatBtnPosition();
                "" == btn.style.bottom ? utils.aniMove(btn, {
                    bottom: 0,
                    b: -btn.offsetHeight
                }, 15) : (btn.style.bottom = -btn.offsetHeight + "px",
                    utils.aniMove(btn, {
                        bottom: parseFloat(bpos.bottom.split("px")[0]),
                        b: -btn.offsetHeight
                    }, 15))
            }
            window.qimoChatClick = function() {
                qimo_loaded ? qimosdk.openChat() : alert("页面尚未加载完，请稍后点击咨询")
            }
                ,
                window.getUnReadMsgCount = function(sid, callback) {
                    var sidData = "";
                    if (sid && (sidData = sid),
                        qimo_loaded)
                        utils.unReadMsgCountCallback = callback,
                            document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("getUnReadMsgCount_" + sidData, "*");
                    else {
                        callback({
                            message: "Loading is not complete, please wait",
                            success: !1
                        })
                    }
                }
                ,
                window.getUnReadMsgList = function(sid, page, callback) {
                    var sidData = "";
                    if (sid && (sidData = sid),
                        qimo_loaded) {
                        utils.unReadMsgListCallback = callback;
                        var dataClone = {
                            sid: sidData,
                            page: page || 1
                        }
                            , advConfigData = JSON.stringify(dataClone);
                        document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("getUnReadMsgList_" + advConfigData, "*")
                    } else {
                        callback({
                            message: "Loading is not complete, please wait",
                            success: !1
                        })
                    }
                }
                ,
            onlineData.haveAuthrizedCheck || qimosdk.validateEmebedState(qimo_config.accessId, qimo_config.location)
        }
}
getSeoParams(),
    function(doc) {
        function getMsgFromChildFrame(b) {
            var data = b.data
                , chatIframe = (b.source,
                b.origin,
                document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow);
            if (document.getElementById("qimo_screenpop"))
                var screenIframe = document.getElementById("qimo_screenpop").getElementsByTagName("iframe")[0].contentWindow;
            "hideChatBox" == b.data && (qimosdk.hideChatBox(),
            qimosdk.autoInviteChat() && ("1" === onlineData.autoShowInviteType || void 0 === onlineData.autoShowInviteType) && onlineData.closeStayTime && "0" !== onlineData.closeStayTime && (0 !== openTimeout && window.clearTimeout(openTimeout),
                openTimeout = window.setTimeout(function() {
                    qimosdk.openChat()
                }, 1e3 * onlineData.closeStayTime)),
            "2" === onlineData.autoShowInviteType && qimosdk.autoInviteChat() && onlineData.closeStayTime && "0" !== onlineData.closeStayTime && (0 !== openTimeout && window.clearTimeout(openTimeout),
                openTimeout = window.setTimeout(function() {
                    qimosdk.openInviteBox()
                }, 1e3 * onlineData.closeStayTime)),
                (talking = {})["qimo_talking_" + qimo_config.accessId] = !1,
                utils.setCookie(talking, "", 1 / 48));
            "closeChatBox" == b.data && (qimosdk.closeChatBox(),
            qimosdk.autoInviteChat() && ("1" === onlineData.autoShowInviteType || void 0 === onlineData.autoShowInviteType) && onlineData.closeStayTime && "0" !== onlineData.closeStayTime && (0 !== openTimeout && window.clearTimeout(openTimeout),
                openTimeout = window.setTimeout(function() {
                    qimosdk.openChat()
                }, 1e3 * onlineData.closeStayTime)),
            "2" === onlineData.autoShowInviteType && qimosdk.autoInviteChat() && onlineData.closeStayTime && "0" !== onlineData.closeStayTime && (0 !== openTimeout && window.clearTimeout(openTimeout),
                openTimeout = window.setTimeout(function() {
                    qimosdk.openInviteBox()
                }, 1e3 * onlineData.closeStayTime)),
                (talking = {})["qimo_talking_" + qimo_config.accessId] = !1,
                utils.setCookie(talking, "", 1 / 48));
            if ("scrollBody" === b.data && window.setTimeout(function() {
                document.body.scrollTop = document.body.scrollHeight,
                    window.scrollTo(0, document.body.scrollHeight)
            }, 100),
            "loadSocketJs" == b.data) {
                qimo_loaded = !0,
                    window.qimoChatLoaded = !0;
                var btn = document.getElementById("chatBtn");
                qimo_config.autoShow && "false" !== qimo_config.autoShow && (btn.style.display = "block");
                var bpos = utils.chatBtnPosition();
                if ("" == btn.style.bottom ? utils.aniMove(btn, {
                    bottom: 0,
                    b: -btn.offsetHeight
                }, 15) : (btn.style.bottom = -btn.offsetHeight + "px",
                    utils.aniMove(btn, {
                        bottom: parseFloat(bpos.bottom.split("px")[0]),
                        b: -btn.offsetHeight
                    }, 15)),
                    qimo_config.m7webchatpage)
                    var interval = setInterval(void (qimo_loaded && (qimosdk.openChat(),
                        clearInterval(interval))), 500);
                else {
                    var key = "qimo_talking_" + qimo_config.accessId;
                    "true" != utils.getCookie(key) || utils.isNewPageOpen() || qimo_config.refreshUnreopen || (window.qimo_autoReOpenFromCookie = !0,
                        utils.isFromMobile() ? (document.getElementById("qimo_chatpup").style.opacity = 0,
                            qimosdk.openChat(),
                            window.setTimeout(function() {
                                qimosdk.hideChatBox(),
                                    document.getElementById("qimo_chatpup").style.opacity = 1
                            }, 500)) : qimosdk.openChat())
                }
                void 0 !== qimo_config.reInitCallback && "function" == typeof qimo_config.reInitCallback && window.setTimeout(function() {
                    qimo_config.reInitCallback()
                }, 0)
            }
            if ("ubaLoadDone" === b.data) {
                var onlineDataNew = JSON.stringify(onlineData);
                chatIframe.postMessage("m7OnlineData" + (onlineDataNew || ""), "*")
            }
            if ("AutoOpenChatBox" == b.data && qimosdk.autoInviteChat() && (0 === onlineData.openStayTime ? "1" === onlineData.autoShowInviteType || void 0 === onlineData.autoShowInviteType ? qimosdk.openChat() : "2" === onlineData.autoShowInviteType && qimosdk.openInviteBox() : (0 !== openTimeout && window.clearTimeout(openTimeout),
                openTimeout = window.setTimeout(function() {
                    "1" === onlineData.autoShowInviteType || void 0 === onlineData.autoShowInviteType ? qimosdk.openChat() : "2" === onlineData.autoShowInviteType && qimosdk.openInviteBox()
                }, 1e3 * onlineData.openStayTime))),
            "openChatBox" == b.data && ("1" === onlineData.autoShowInviteType || void 0 === onlineData.autoShowInviteType ? qimosdk.openChat() : "2" === onlineData.autoShowInviteType && (qimosdk.openInviteBox(),
            openTimeout && (window.clearTimeout(openTimeout),
                openTimeout = 0))),
            "newMsg" == b.data && message.show(),
            "string" == typeof b.data && -1 < b.data.indexOf("userBehaviorReplayData")) {
                var userBehaviorReplayData = JSON.parse(b.data).userBehaviorReplayData;
                qimosdk.userBehaviorPlaybackInit(userBehaviorReplayData.clackApiUrl, userBehaviorReplayData.siteId)
            }
            if ("string" == typeof b.data && -1 != b.data.indexOf("openVideoBox")) {
                var videomsg = JSON.parse(b.data.substring("openVideoBox".length));
                qimosdk.openVideo(videomsg)
            }
            if ("wantCloseChat" == b.data) {
                if (qimosdk.mini) {
                    var videoDom = document.getElementById("qimo_videopup")
                        , minimg = document.getElementById("qimo_minimg")
                        , maximg = document.getElementById("qimo_maximg");
                    minimg.style.display = "block",
                        maximg.style.display = "none",
                        videoDom.style.width = "700px",
                        videoDom.style.height = "500px",
                        videoDom.style.left = "35%",
                        videoDom.style.top = "20%"
                }
                qimosdk.closeTip = !0,
                    screenIframe.postMessage("wantCloseChat", "*")
            }
            if ("confirmCloseChat" == b.data && chatIframe.postMessage("confirmCloseChat", "*"),
            "wantCloseConfirm" == b.data && (qimosdk.closeShareScreen(),
                chatIframe.postMessage("wantCloseConfirm", "*")),
            "cancelCloseChat" == b.data && (qimosdk.closeTip = !1),
            "string" != typeof b.data || -1 === b.data.indexOf("UserHangup") && "UserCancel" != b.data && "beRefused" != b.data && "beHanguped" != b.data || qimosdk.CloseVideo(),
            "UserHangup" == b.data && chatIframe.postMessage("UserHangup", "*"),
            "UserCancel" == b.data && chatIframe.postMessage("UserCancel", "*"),
            "string" == typeof b.data && -1 !== b.data.indexOf("notSupport") && (qimosdk.CloseVideo(),
                chatIframe.postMessage("notSupport" + b.data.substring("notSupport".length), "*")),
            "string" == typeof b.data && -1 !== b.data.indexOf("lostConnect") && (qimosdk.CloseVideo(),
                chatIframe.postMessage("lostConnect" + b.data.substring("lostConnect".length), "*")),
            "unreadMessageCount" === b.data && 0 === utils.chatboxProp.isChatBoxShow) {
                unreadMessageCount++;
                var badage = document.getElementById("qimo_badge");
                0 < unreadMessageCount ? (badage.style.display = "block",
                    badage.innerHTML = unreadMessageCount < 100 ? unreadMessageCount : "99+") : badage.style.display = "none"
            }
            if ("string" == typeof b.data && -1 !== b.data.indexOf("showNewMessage")) {
                var newMsg = JSON.parse(b.data.substring("showNewMessage".length));
                qimosdk.m7showNewMsg(newMsg)
            }
            if ("withdrawMessageCount" === b.data && 0 === utils.chatboxProp.isChatBoxShow) {
                unreadMessageCount && unreadMessageCount--;
                badage = document.getElementById("qimo_badge");
                0 < unreadMessageCount ? (badage.style.display = "block",
                    badage.innerHTML = unreadMessageCount < 100 ? unreadMessageCount : "99+") : badage.style.display = "none"
            }
            if ("string" == typeof b.data && -1 < b.data.indexOf("talkingNow")) {
                var talking = JSON.parse(b.data.substring("talkingNow".length));
                utils.setCookie(talking, "", 1 / 48)
            }
            if ("moorChatIsReady" === b.data) {
                if (onlineData.advConfig) {
                    onlineData.advConfig.styleColor = onlineData.cssStyle.styleColor,
                    onlineData.chatboxHeight && (onlineData.advConfig.chatboxHeight = onlineData.chatboxHeight);
                    var advConfigData = JSON.stringify(onlineData.advConfig);
                    document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("advConfigData_" + advConfigData, "*")
                } else
                    document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("advConfigData_", "*");
                qimo_config.m7webchatpage && document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("m7webChatPage_", "*")
            }
            if ("string" == typeof b.data && -1 !== b.data.indexOf("openShareScreen")) {
                var screenmsg = JSON.parse(b.data.substring("openShareScreen".length));
                qimosdk.openShareScreen(screenmsg)
            }
            if ("string" == typeof b.data && -1 < b.data.indexOf("ShareEnd") && (qimosdk.closeShareScreen(),
                chatIframe.postMessage("ShareEnd", "*")),
            "closeShare" === b.data && qimosdk.closeShareScreen(),
            "string" == typeof b.data && -1 < b.data.indexOf("parentsaveSid")) {
                var obj = JSON.parse(b.data.substring("parentsaveSid".length));
                utils.setCookie(obj, "", 1e3)
            }
            if ("string" == typeof b.data && "loadVideoJs" === b.data) {
                var videoScript = qimo_config.chatHost + "javascripts/external_api.js"
                    , recorder = qimo_config.chatHost + "javascripts/recorder.js";
                qimosdk.loadVedioJs(videoScript),
                    qimosdk.loadVedioJs(recorder)
            }
            if ("string" == typeof b.data && -1 < b.data.indexOf("getUnReadMsgCount_")) {
                var davData = {};
                data.substring("getUnReadMsgCount_".length) && (davData = JSON.parse(data.substring("getUnReadMsgCount_".length))),
                "function" == typeof utils.unReadMsgCountCallback && utils.unReadMsgCountCallback(davData)
            }
            if ("string" == typeof b.data && -1 < b.data.indexOf("getUnReadMsgList_")) {
                davData = {};
                data.substring("getUnReadMsgList_".length) && (davData = JSON.parse(data.substring("getUnReadMsgList_".length))),
                "function" == typeof utils.unReadMsgListCallback && utils.unReadMsgListCallback(davData)
            }
            "webchatReload" === b.data && location.reload()
        }
        window.qimo_autoReOpenFromCookie = !1,
            window.addEventListener ? window.addEventListener("message", getMsgFromChildFrame) : window.attachEvent("onmessage", getMsgFromChildFrame);
        var qimosdk = new QiMoIMSDK;
        (window.qimosdk = qimosdk).initChat(onlineData, function(data) {
            qimosdk.afterInit()
        }),
            qimosdk.initInviteBox(),
        window.FormData && (qimosdk.initScreen(),
            qimosdk.initVideo()),
            window.validateEmebedState = function(data) {}
            ,
        window.mobileHisAddListen && window.mobileHisAddListen(qimosdk);
        var currentPv = utils.getCookie("pageViewNum") ? parseInt(utils.getCookie("pageViewNum")) : 0;
        currentPv++,
            utils.setCookie("pageViewNum", currentPv);
        var hiddenTime = "";
        document.addEventListener("visibilitychange", function(e) {
            (document.hidden || document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("dealImMsg_", "*"),
                utils.isFromMobile()) && ("hidden" == document.visibilityState ? hiddenTime = (new Date).getTime() : 10 < ((new Date).getTime() - hiddenTime) / 1e3 && document.getElementById("qimo_chatpup").getElementsByTagName("iframe")[0].contentWindow.postMessage("heartCheck_", "*"))
        })
    }(document);
